#include "StdAfx.h"

#include "FirstIntersectionResult.h"
#include "SecondIntersectionResult.h"
#include "Intersectable.h"
#include "Light.h"
#include "ColorUtils/Image.h"
#include "ColorUtils/DataImage.h"
#include "Scene.h"
#include "World.h"

#include "DirectedLight.h"

DirectedLight::DirectedLight(Scene_ptr scene, const Direction& direction, const Color& intensity) 
	: _scene(scene), _direction(direction), _intensity(intensity)
{
	_direction *= -1;
}

Ray DirectedLight::IntensityAtPoint(const Point& point)
{
	SecondIntersectionResult tempResult = SecondIntersectionResult();

	_scene->IntersectionFinder->WhereIntersects(Ray(point + _direction * 0.0005, _direction), tempResult);
	if (tempResult.Distance == std::numeric_limits<double>::infinity())
		return Ray(_intensity, _direction);

	return Ray(Point(0, 0, 0), _direction);
}

DirectedLight::~DirectedLight() {};
